//
//  CustomBelowTextView.m
//  TY_MotorRemoteControl
//
//  Created by xiaomei su on 2018/3/2.
//  Copyright © 2018年 xuweixin. All rights reserved.
//

#import "CustomBelowTextView.h"

@implementation CustomBelowTextView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (instancetype)init{
    
    self = [super init];
    if (self) {
//        self.opaque = NO;
//        self.backgroundColor = [UIColor redColor];

    }
    return self;
    
}

-(void)drawRect:(CGRect)rect{
    [super drawRect:rect];
    // 下面两句代码的作用就是填充背景色
    [[UIColor colorWithRed:30/255.0 green:26/255.0 blue:23/255.0 alpha:1] setFill];
    UIRectFill(rect);
    CGContextRef context = UIGraphicsGetCurrentContext();
    
//    CGContextClearRect(context, rect);//添加这句代码
//    self.backgroundColor = [UIColor redColor];
    CGFloat height = rect.size.height;
//    CGFloat width = rect.size.width;
    
    
    
    UIFont *font1 = [UIFont systemFontOfSize:11];
    [@"UNLOCK" drawInRect:CGRectMake(13, 4, 50, 14) withAttributes:@{NSFontAttributeName:font1,NSForegroundColorAttributeName:[UIColor whiteColor]}];
    
    // 左三角形
    CGPoint points[3];
    points[0] = CGPointMake(3, height);
    points[1] = CGPointMake(7, height-3);
    points[2] = CGPointMake(9, height);
    CGContextAddLines(context, points, 3);
    CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor);
    CGContextClosePath(context);
    CGContextDrawPath(context, kCGPathFill);
    //左下划线
    CGPoint left_linePoints[2];
    left_linePoints[0] = CGPointMake(8, height);
    left_linePoints[1] = CGPointMake(60, height);
    CGContextAddLines(context, left_linePoints, 2);
    CGContextDrawPath(context, kCGPathFillStroke);
    
    UIFont *font2 = [UIFont systemFontOfSize:15];
    [@"MOTORCYCLE" drawInRect:CGRectMake(61, 3, 103, 17) withAttributes:@{NSFontAttributeName:font2,NSForegroundColorAttributeName:[UIColor whiteColor]}];
    
    //右下划线
    CGPoint right_linePoints[2];
    right_linePoints[0] = CGPointMake(164, height);
    right_linePoints[1] = CGPointMake(201, height);
    CGContextAddLines(context, right_linePoints, 2);
    CGContextDrawPath(context, kCGPathFillStroke);
    
    [@"LOCK" drawInRect:CGRectMake(165, 4, 37, 14) withAttributes:@{NSFontAttributeName:font1,NSForegroundColorAttributeName:[UIColor whiteColor]}];
    
    //右三角形
    CGPoint r_points[3];
    r_points[0] = CGPointMake(200, height);
    r_points[1] = CGPointMake(202, height-3);
    r_points[2] = CGPointMake(206, height);
    CGContextAddLines(context, r_points, 3);
    CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor);
    CGContextClosePath(context);
    CGContextDrawPath(context, kCGPathFill);
    
    
}
@end
